﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Tencent.OA.ACM.Entity.RouteInfo>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeaderPlaceHolder" runat="server">
    <link href="<%= this.Url.Content("~/Content/jquery.fmext.css") %>" rel="stylesheet"
        type="text/css" />

    <script type="text/javascript" language="javascript" src="<%=this.Url.Content("~/content/Scripts/MicrosoftAjax.js") %>"></script>

    <script type="text/javascript" language="javascript" src="<%=this.Url.Content("~/content/Scripts/MicrosoftMvcValidation.js") %>"></script>

    <script type="text/javascript" language="javascript" src="<%=this.Url.Content("~/content/staffChooser.js") %>"></script>

    <script type="text/javascript" language="javascript" src="<%=this.Url.Content("~/content/Scripts/jquery.fmext.js") %>"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="mainContainerPlaceHolder" runat="server">
    <div class="title ">
        新增路线
    </div>
    
    <% Html.EnableClientValidation(); %>
    <% using (Html.BeginForm()) {%>
        <%= Html.ValidationSummary(true) %>
        
    <div class="form_table">
        <table cellpadding="0" cellspacing="0" style="width: 100%">
            <tr>
                <th>
                    路线名：
                </th>
                <td>
                    <%=Html.TextBoxFor(model => model.RouteName, new { maxlength=40})%><span class="required">*</span>
                    <span style="color: #999;">推荐格式为：一位字母+三位数字，如:S-001</span>
                    <br />
                    <%= Html.ValidationMessageFor(model => model.RouteName)%>
                </td>
            </tr>
            <tr>
                <th>
                    城 市：
                </th>
                <td>
                    <%--<%=Html.DropDownList("Area", new List<SelectListItem>() {   new SelectListItem() { Text = "深圳", Value = "0" },
                                                                                         new SelectListItem() { Text = "成都", Value = "1" },
                                                                                         new SelectListItem() { Text = "北京", Value = "1" },
                                                                                         new SelectListItem() { Text = "上海", Value = "1" }})%><span class="required">*</span> --%>
                    <%=Html.DropDownList("CityId", Tencent.OA.ACM.App.Controllers.CityInfoController.BindDropDownList())%><span class="required">*</span>
                    <br />
                    <%= Html.ValidationMessageFor(model => model.CityId)%>
                </td>
            </tr>
            <tr>
                <th>
                    班车属性：
                </th>
                <td>
                    <%--<%=Html.DropDownList("RouteTpe", new List<SelectListItem>() {   new SelectListItem() { Text = "上班路线", Value = "0" },
                                                                                         new SelectListItem() { Text = "下班路线", Value = "1" },
                                                                                         new SelectListItem() { Text = "客服路线", Value = "1" },
                                                                                         new SelectListItem() { Text = "夜班路线", Value = "1" } } )%><span class="required">*</span>--%>                            
                   <%=Html.DropDownList("BusTypeId", Tencent.OA.ACM.App.Controllers.BusTypeController.BindDropDownList())%><span class="required">*</span>
                    <br />
                    <%= Html.ValidationMessageFor(model => model.BusTypeId)%>
                </td>
            </tr>
            <tr>
                <th>
                    路线卡号码：
                </th>
                <td>
                    <%=Html.TextBox("RouteCardId","", new { maxlength=20})%><span class="required">*</span>
                    <br />
                    <%= Html.ValidationMessageFor(model => model.RouteCardId)%>
                </td>
            </tr>
            <tr>
                <th>
                    台 次：
                </th>
                <td>
                    <%=Html.TextBox("BusNumber", "", new { maxlength = 10 })%><span class="required">*</span>
                    <br />
                    <%= Html.ValidationMessageFor(model => model.BusNumber)%>
                </td>
            </tr>
            <tr>
                <th>
                    运行方向：
                </th>
                <td>
                    <%=Html.DropDownList("BusDirection", new List<SelectListItem>() {  new SelectListItem() { Text = "上班方向", Value = "0" },
                                                                                         new SelectListItem() { Text = "下班方向", Value = "1" } })%><span class="required">*</span>       
                </td>
            </tr>
            <tr>
                <th>
                    运行时间：
                </th>
                <td>
                    <span><%=Html.CheckBox("Monday", new {@class="workDay" })%>周一</span>
                    <span><%=Html.CheckBox("Tuesday", new { @class = "workDay" })%>周二</span>
                    <span><%=Html.CheckBox("Wednesday", new { @class = "workDay" })%>周三</span>
                    <span><%=Html.CheckBox("Thursday", new { @class = "workDay" })%>周四</span>
                    <span><%=Html.CheckBox("Friday", new {@class="workDay" })%>周五</span>
                    <span><%=Html.CheckBox("Saturday")%>周六</span>
                    <span><%=Html.CheckBox("Sunday")%>周日</span>
                    <span style="color:#999;">(<%=Html.CheckBox("workDay")%>周一至周五)</span>
                    <span class="required">*</span>
                    <span id="WorkWeekMessage"  style="color:Red; display:none;">运行时间不能为空</span>
                </td>
                <br />
                <%= Html.ValidationMessageFor(model => model.WorkingWeek)%>
            </tr>
            <tr>
                <th>
                    容纳人数：
                </th>
                <td>
                    <%=Html.TextBox("MaxPeoples", "", new { maxlength = 10 })%><span class="required">*</span>
                    <br />
                    <%= Html.ValidationMessageFor(model => model.MaxPeoples)%>
                </td>
            </tr>
            <tr>
                <th>
                    负责人：
                </th>
                <td>
                    <%= Html.TofUserChooserFor(model => model.Responser, true, "getTofUserID")%>
                    <input type="hidden" id="UseUserIDs" />
                </td>
            </tr>
            <tr>
                <th style="vertical-align:top;">
                    站 点：
                </th>
                <td>
                    <%=Html.TextArea("Stations", "", new { style = "width:400px;height:100px;maxlength:1000;", onkeypress = "return limitTextArea(this,500);", onpropertychange = "return limitTextArea(this,500);" })%>
                    <span class="required">*</span>
                    <br />
                    <%= Html.ValidationMessageFor(model => model.Stations)%>
                    <div style="color: #999;">
                        提示：站点和到站时间使用<span class="required">半角逗号</span>分隔开，每行输入一个站点和对应的到站时间，如：
                         <br />腾讯大厦,08:50
                         <br />飞亚达,08:51
                        <br />如不提供到站时间，则不需要<span class="required">半角逗号</span>，如：
                        <br />腾讯大厦
                         <br />飞亚达
                        </div>
                </td>
            </tr>
            <tr>
                <th>
                    计算站点GPS坐标：
                </th>
                <td>
                    <%=Html.CheckBox("IsNeedComputeGpsForChkBox", true)%>
                </td>
            </tr>
            <tr>
                <th>
                    备 注：
                </th>
                <td>
                    <%=Html.TextArea("Remark", new { style = "width:400px;height:100px;maxlength:1000;", onkeypress = "return limitTextArea(this,500);", onpropertychange = "return limitTextArea(this,500);" })%>
                </td>
            </tr>
              <tr>
                <th>
                    &nbsp;
                </th>
                <td>
                    <input type="button" value="保 存" onclick="javascript:save();" />
                    <input type="button" value="取 消" onclick="window.location='<%=this.Url.Content("~/Route") %>'" />
                </td>
            </tr>
        </table>
    </div>
    
    <% } %>
    
    <script type="text/javascript">

        //员工选择器初始化
        $('.staffChooser').each(function() {
            $(this).staffChooser(true);
            $("#workDay").click(function() {
                var checked = $(this).attr("checked");
                $(".workDay").attr("checked", checked);
            });
        });

        //从员工选择器获取员工ID
        function getTofUserID(e, data, formatted) {
            if (data) {
                var userIDs = $("#UseUserIDs").val();
                $("#UseUserIDs").val(userIDs + data.ID + ";");
            }
        }
        
        //输入验证
        function checkInput() {

            //输入空格清空
            $("#RouteName").val(trim($("#RouteName").val()));
            $("#RouteCardId").val(trim($("#RouteCardId").val()));
            $("#BusNumber").val(NumberZen2Han(trim($("#BusNumber").val())));
            $("#MaxPeoples").val(NumberZen2Han(trim($("#MaxPeoples").val())));
            $("#Stations").val(trim($("#Stations").val()));

            //手工激活表单验证
            var errors = Sys.Mvc.FormContext.getValidationForForm(document.getElementsByTagName("form")[0]).validate('submit');
            if (errors.length > 0)
                return false;

            var retValue = true;

            if (!($("#Monday").attr("checked") || $("#Tuesday").attr("checked") || $("#Wednesday").attr("checked")
                || $("#Thursday").attr("checked") || $("#Friday").attr("checked") || $("#Saturday").attr("checked") || $("#Sunday").attr("checked"))) {
                $("#WorkWeekMessage").show();
                retValue = false;
            }
            else
                $("#WorkWeekMessage").hide();

            return retValue;
        }

        //保存
        function save() {
            if (!checkInput()) {
                return;
            }

            document.forms[0].submit();
        }
        //限制textarea输入文本长度
        function limitTextArea(obj, maxlength) {
            var contents = obj.value;
            if (contents.length <= maxlength)
                return true;
            else {
                obj.value = contents.substring(0, maxlength);
            }
        }
    </script>
</asp:Content>
